return [qmenu.item("&Force to nearest %s deg.\tCtrl" % quarkx.ftos(anglestep), forceangle1click,
"|This command forces the angle to a 'round' value. It works like a kind of grid for angles.\n\nSet the 'angle grid' in the Configuration box, Map, Building, 'Force to angle'. See also the Options menu, 'Adjust angles automatically'.")]
def updatecenters(item,delta):
if item["usercenter"]:
center = quarkx.vect(item["usercenter"])
item["usercenter"]=(center+delta).tuple
for subitem in item.subitems:
# debug('subitem '+subitem.name)
updatecenters(subitem,delta)
class CenterHandle(GenericHandle):
"Handle at the center of an object."
hint = "move (Ctrl key: force to grid)|move with the mouse"
"Like CenterHandle but displays an icon instead of a square."
def __init__(self, pos, centerof, icon=None):
CenterHandle.__init__(self, pos, centerof)
if icon is None:
#
# Get the default icon for the given entity.
#
icon = centerof.geticon(1)
self.icon = icon
self.size = (8,8)
def draw(self, view, cv, draghandle=None):
p = view.proj(self.pos)
if p.visible:
cv.draw(self.icon, p.x-8, p.y-8)
#
# 3D views "eye" handles.
#
class EyePosition(GenericHandle):
hint = "camera for the 3D view||This 'eye' represents the position of the camera of the 3D perspective view. You can use it to quickly move the camera elsewhere.\n\nIf several 3D views are opened, you will see several 'eyes', one for each camera."
def __init__(self, view, view3D):
pos, roll, pitch = view3D.cameraposition
GenericHandle.__init__(self, pos)
self.view3D = view3D
self.normal = angles2vec1(pitch * rad2deg, roll * rad2deg, 0)
hint = "camera direction||This is the direction the 'eye' is looking to. You can use it to quickly rotate the camera with the mouse.\n\nThe 'eye' itself represents the position of the camera of the 3D perspective view. You can use it to quickly move the camera elsewhere.\n\nIf several 3D views are opened, you will see several 'eyes', one for each camera."
self.view3D.cameraposition = pos, roll * deg2rad, pitch * deg2rad
if flags&MB_DRAGGING:
return [], [], av
return None, None, av
#
# Linear Mapping Circle handles.
#
class LinearHandle(GenericHandle):
"Linear Box handles."
def __init__(self, pos, mgr):
GenericHandle.__init__(self, pos)
self.mgr = mgr # a LinHandlesManager instance
def drag(self, v1, v2, flags, view):
delta = v2-v1
if flags&MB_CTRL:
g1 = 1
else:
delta = aligntogrid(delta, 0)
g1 = 0
if delta or (flags&MB_REDIMAGE):
new = map(lambda obj: obj.copy(), self.mgr.list)
if not self.linoperation(new, delta, g1, view):
if not flags&MB_REDIMAGE:
new = None
else:
new = None
return self.mgr.list, new
def linoperation(self, list, delta, g1, view):
matrix = self.buildmatrix(delta, g1, view)
if matrix is None: return
for obj in list:
obj.linear(self.center, matrix)
return 1
class LinRedHandle(LinearHandle):
"Linear Box: Red handle at the center."
hint = "move selection (Ctrl key: force to grid)|move selection"
def __init__(self, pos, mgr):
LinearHandle.__init__(self, pos, mgr)
self.cursor = CR_MULTIDRAG
def draw(self, view, cv, draghandle=None):
p = view.proj(self.pos)
if p.visible:
cv.reset()
cv.brushcolor = self.mgr.color
cv.rectangle(p.x-3, p.y-3, p.x+4, p.y+4)
def linoperation(self, list, delta, g1, view):
for obj in list:
obj.translate(delta, g1 and grid[0])
self.draghint = vtohint(delta)
return delta
class LinSideHandle(LinearHandle):
"Linear Box: Red handle at the side for distortion/shearing."
undomsg = Strings[527]
hint = "enlarge / shear (Ctrl key: either enlarge or shear)||This handle lets you distort the selected object(s).\n\nIf you move the handle in the direction of or away from the center, you will shrink or enlarge the objects correspondingly. If you move the handle in the other direction, you will 'shear' the objects. Hold down the Ctrl key to prevents the objects from being enlarged and sheared at the same time."
def __init__(self, center, side, dir, mgr, firstone):
# diff = v * (npos - self.center) / (v.x*v.x+v.y*v.y+v.z*v.z)
# if abs(diff-1) < epsilon: return
# dir = self.dir
# return quarkx.matrix(
# (dir!=0 or diff, 0, 0),
# (0, dir!=1 or diff, 0),
# (0, 0, dir!=2 or diff))
class LinCornerHandle(LinearHandle):
"Linear Box: Red handle at the corner for rotation/zooming."
undomsg = Strings[528]
hint = "zoom / rotate (Ctrl key: either zoom or rotate)||This handle lets you rotate and scale the selected object(s).\n\nIf you move the handle in the direction of or away from the center, you will zoom the objects and make them smaller or larger. If you move the handle around the center, the objects rotate. Hold down the Ctrl key to prevent zooming and rotation to occur simultaneously."
def __init__(self, center, pos1, mgr, realpoint=None):